use vudu
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[ConsultaSeccionMateriaP]
@escuela INT,
@materia INT

AS
BEGIN
	SET NOCOUNT ON;

SELECT S.numeroSeccion, S.id_Seccion, S.fk_Profesor 
FROM Pensum P,PensumMateria PM, SeccionMateria S, Materia M, PeriodoAcademico A 
 WHERE P.fk_id_escuela = @escuela  
                AND P.fechaFin is null 
                AND  P.id_Pensum = PM.fk_id_pensum  
                AND PM.fk_id_materia = S.fk_Materia 
                AND S.fk_Materia = M.id_Materia 
								AND M.id_Materia = @materia
								 AND S.fk_PeriodoAcademico = A.ID_PERIODOACADEMICO 
								 AND GETDATE() BETWEEN A.fechaInicio AND A.fechaFin 
								 GROUP BY S.id_Seccion, S.numeroSeccion,S.fk_Materia, S.fk_Profesor, M.nombreMateria
								 ORDER BY S.id_Seccion

END;